package teacool.web.login;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;
import org.springframework.web.servlet.view.RedirectView;

import teacool.service.login.CreateUser;

public class CreateUserFormController extends SimpleFormController {
	/** Logger for this class and subclasses */
    protected final Log logger = LogFactory.getLog(getClass());

    public ModelAndView onSubmit(Object command) throws ServletException {
    	CreateUser createUser = (CreateUser)command;
    	logger.info("Create new user " + createUser.getUserName() + " for " + createUser.getEmail());
    	return new ModelAndView(new RedirectView(getSuccessView()));
    }
    
    protected Object formBackingObject(HttpServletRequest request) throws ServletException {
        CreateUser createUser = new CreateUser();
        return createUser;
    }
}
